package org.example.controller;

import org.example.config.MinIoProperties;
import org.example.config.MinioUtil;
import org.example.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @BelongsProject：blockchain-APTrace
 * @CreateTime 2024-05-28-20:16
 * @Author SweetPig
 */
@RestController
@RequestMapping("common")
public class CommonController {

    @Autowired
    MinIoProperties minIoProperties;

    @RequestMapping("upload")
    public Result upload(MultipartFile file) throws Exception {
        MinioUtil minioUtil = new MinioUtil(minIoProperties.getEndpoint(), minIoProperties.getBucketName(), minIoProperties.getAccessKeyId(), minIoProperties.getAccessKeySecret());
        String upload = minioUtil.upload(file);
        return Result.success(upload);
    }


}
